/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Admin_AcutUsuario.java
 *
 * Created on 25/09/2010, 13:44:51
 */

package Vista.Administrador;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import org.omg.PortableInterceptor.USER_EXCEPTION;

import Modelo.*;
import Vista.ErrorCampos;
import Vista.ErrorNoEncontrado;
import Vista.VistaController;
import Controlador.*;
/**
 *
 * @author 
 */

public class Admin_AcutUsuario extends javax.swing.JFrame {

    private  Usuario user=null;
    private  ControladorUsuario con= new ControladorUsuario();
    private  Object campos[]=new Object[8];
    private  int Modificar=-1;
    
  
    /** Creates new form Admin_AcutUsuario */
    public Admin_AcutUsuario() {
    	initComponents();
    	campos[0]=direText;
    	campos[1]=userText;
    	campos[2]=nombreText;
    	campos[3]=dniText;
    	campos[4]=password;
    	campos[5]=cp;
    	campos[6]=paisText;
    	campos[7]=localText;
    	   	
        
    }
    public void datosActuUsuarios(){
    	
    	
    	
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollBar1 = new javax.swing.JScrollBar();
        jLabel1 = new javax.swing.JLabel();
        dniText = new javax.swing.JTextField();
        Buscar = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        userText = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        password = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        nombreText = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        dniTextf = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        direText = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        cp = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        localText = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        paisText = new javax.swing.JTextField();
        provinciaText = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        Guardar = new javax.swing.JButton();
        Cancelar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        Eliminar = new javax.swing.JButton();
        permisosCombo = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        Mostrar = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Usuarios");

        jLabel1.setText("Buscar:");
        
        Mostrar.setText("Mostrar");
        Mostrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MostrarActionPerformed(evt);
            }
        });

        Buscar.setText("jButton1");
        Buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BuscarActionPerformed(evt);
            }
        });

        jLabel2.setForeground(new java.awt.Color(153, 153, 153));
        jLabel2.setText("Datos cuenta:");

        jLabel3.setText("Usuario");

        userText.setBackground(new java.awt.Color(204, 204, 204));

        jLabel4.setText("Contraseña");

        password.setBackground(new java.awt.Color(204, 204, 204));

        jLabel5.setForeground(new java.awt.Color(153, 153, 153));
        jLabel5.setText("Datos personales:");

        jLabel6.setText("Nombre");

        nombreText.setBackground(new java.awt.Color(204, 204, 204));
        nombreText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nombreTextActionPerformed(evt);
            }
        });

        jLabel8.setText("DNI");

        dniTextf.setBackground(new java.awt.Color(204, 204, 204));
        dniTextf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dniTextfActionPerformed(evt);
            }
        });

        jLabel9.setText("Direccion");

        direText.setBackground(new java.awt.Color(204, 204, 204));

        jLabel11.setText("Telefono");

        jLabel12.setText("CP");

        cp.setBackground(new java.awt.Color(204, 204, 204));

        jLabel13.setText("Localidad");

        localText.setBackground(new java.awt.Color(204, 204, 204));

        jLabel14.setText("Provincia");

        jLabel15.setText("Pais");

        paisText.setBackground(new java.awt.Color(204, 204, 204));
        paisText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                paisTextActionPerformed(evt);
            }
        });

        provinciaText.setBackground(new java.awt.Color(204, 204, 204));

        jLabel16.setText("Permisos");

        Guardar.setText("Guardar");
        Guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GuardarActionPerformed(evt);
            }
        });

        Cancelar.setText("Cancelar");

        model = new javax.swing.table.DefaultTableModel(null,new String [] {"Nombre", "Id", "Permisos" }); 
        jTable1.setModel(model);
        jScrollPane1.setViewportView(jTable1);

        Eliminar.setText("Eliminar");

        permisosCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Vendedor", "Encargado", "Administrador" }));

        jLabel17.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel17.setForeground(new java.awt.Color(153, 153, 153));
        jLabel17.setText("Usuarios:");

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane2.setViewportView(jTextArea1);

        jButton1.setText("Actualizar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel9)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel6)
                                                .addComponent(jLabel8)
                                                .addComponent(jLabel12)
                                                .addComponent(jLabel15)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(paisText)
                                                .addComponent(cp)
                                                .addComponent(dniTextf)
                                                .addComponent(nombreText, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(direText, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel13)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(localText, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel14)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(provinciaText, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel11)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(18, 18, 18)
                                .addComponent(jButton1)
                                .addGap(46, 46, 46))
                            .addComponent(jLabel2)
                            .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
                            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel16))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(permisosCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(userText, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    	.addComponent(Mostrar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)	
                        .addComponent(Guardar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Eliminar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Cancelar)
                        .addGap(24, 24, 24))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dniText, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(329, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addContainerGap(473, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(dniText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Buscar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(userText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(permisosCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(nombreText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(dniTextf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(direText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(cp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(jLabel15)
                            .addComponent(paisText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(provinciaText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(localText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Guardar)
                    .addComponent(Eliminar)
                    .addComponent(Cancelar)
                    .addComponent(Mostrar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void nombreTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nombreTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nombreTextActionPerformed

    private void dniTextfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dniTextfActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_dniTextfActionPerformed

    private void paisTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_paisTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_paisTextActionPerformed
    
    public void removerFilas() {
        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        modelo.setNumRows(0);
    }
    public void MostrarDatos(Usuario p){
    	 
        userText.setText(p.getNombre_usuario());
     	password.setText(p.getPassword());
     	nombreText.setText(p.getNombre());
     	dniTextf.setText(""+p.getDni());
     	cp.setText(""+p.getCodigo_postal());
     	paisText.setText(p.getPais());
     	localText.setText(p.getLocalidad());
     	provinciaText.setText(p.getProvincia());
     	if (p.getPermisos().equals("Administrador")) permisosCombo.setSelectedIndex(2);
         if (p.getPermisos().equals("Vendedor")) permisosCombo.setSelectedIndex(0);
         if (p.getPermisos().equals("Encargado")) permisosCombo.setSelectedIndex(1);
    }
    
    public void MostrarActionPerformed(java.awt.event.ActionEvent evt){
    	

        int index = jTable1.getSelectedRow();
        if (index != -1) {
            Usuario p = (Usuario) jTable1.getValueAt(index, 0);
            MostrarDatos(p);
            Modificar=p.getID();
        }
    	
    }
    
    
    private void BuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BuscarActionPerformed
        // TODO add your handling code here:
        ControladorUsuario u=new ControladorUsuario();
        //Object [] users =u.buscarUsuarioDNI(dniText.getText());
        removerFilas();
        //if(dniText.getText()==null){
       // Object [][] users_tabla=new Object [users.length] [3];
        
        if(dniText.getText()!=null){
        	
        	Object [] users =u.buscarUsuarioDNI(dniText.getText());
        	Object [][] users_tabla=new Object [users.length] [3];
        	int cantidad=model.getRowCount();
            
            
            for (int i=0;i<cantidad;i++)
            		model.removeRow(0);
            
            for (int i=0;i<users.length-1;i++){
            	user=(Usuario)users[i];
            	
            	Object users_line [] ={ user, user.getNombre_usuario(), user.getPermisos() };
            	model.addRow(users_line);
            	users_tabla[i]=users_line;
            	}
        }
        else{
        	 Object [] users =u.buscarUsuarioDNI(dniText.getText());
        	 Object [][] users_tabla=new Object [users.length] [3];
        	 int cantidad=model.getRowCount();
        
      
        for (int i=0;i<cantidad;i++)
        		model.removeRow(0);
        
        for (int i=0;i<users.length-1;i++){
        	user=(Usuario)users[i];
        	
        	Object users_line [] ={ user, user.getNombre_usuario(), user.getPermisos() };
        	model.addRow(users_line);
        	users_tabla[i]=users_line;
        	}
    /*    if(dniText.getText()!=null){
        	
        	user = u.buscarUsuarioDNI(dniText.getText());
        	if(user!=null){
        	
        	MostrarDatos(user);
        	}
        	else {
        		ErrorNoEncontrado error= new ErrorNoEncontrado();
        		error.setVisible(true);
        }
        }*/
     //   }

    }//GEN-LAST:event_BuscarActionPerformed
    }
    private void GuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GuardarActionPerformed

        ControladorUsuario con= new ControladorUsuario();


        
       /*
        String campo_incopmpleto=VistaController.camposObligatorios(campos);
    	if(campo_incopmpleto!=null){
        */	
        String campo_incopmpleto="";
        if(true){
        	Usuario nuevo=new Usuario (Integer.parseInt(dniTextf.getText()),nombreText.getText(),direText.getText(),null,null,Integer.parseInt(cp.getText()),paisText.getText(),provinciaText.getText(),localText.getText(),userText.getText(),password.getText(),(String)permisosCombo.getSelectedItem(),0);
    		if (Modificar!=-1)
    			con.actualizarUsuario(Modificar,nuevo);
    		else
    			con.actualizarUsuario(nuevo);
        } else {
        	ErrorCampos error =new ErrorCampos();
        	error.setVisible(true);
        }
        	
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Admin_AcutUsuario().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Buscar;
    private javax.swing.JButton Mostrar;
    private javax.swing.JButton Cancelar;
    private javax.swing.JButton Eliminar;
    private javax.swing.JButton Guardar;
    private javax.swing.JTextField cp;
    private javax.swing.JTextField direText;
    private javax.swing.JTextField dniText;
    private javax.swing.JTextField dniTextf;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollBar jScrollBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField localText;
    private javax.swing.JTextField nombreText;
    private javax.swing.JTextField paisText;
    private javax.swing.JTextField password;
    private javax.swing.JComboBox permisosCombo;
    private javax.swing.JTextField provinciaText;
    private javax.swing.JTextField userText;
    private javax.swing.table.DefaultTableModel model;
    // End of variables declaration//GEN-END:variables

}
